Add missing STD Library Identifiers#7325
Conversation
75edd8c to
a5a449b
Compare
danmar
left a comment
There was a problem hiding this comment.
hmm.. some tests would be nice. Do you have some idea? I don't feel we need to test this in full but some kind of generic tests would be nice.. maybe ensure C11_STDLIB_IDENTIFIERS extends C99_STDLIB_IDENTIFIERS, make a few isStdLibId calls to make sure it works, ..
@danmar Test suggestions sound good, I can add that. is there already a test file where the misra.py is „unit tested“? I only found the .c file which tests the detections. If yes could you link the file where I should add it, if no could you make a suggestion how you would like to have the test added? with test suggestions I don’t have additional ideas, the thing is it’s only a big list of keywords so there is not much to test, apart of the suggestions you already mentioned. |
|
@danmar added a Test and also checked the isKeyword additionally to isStdLib and fixed a typo there, too. If it is fine from your side it can be merged. |
|
@wienans thanks! I wonder, is your name added in https://github.com/danmar/cppcheck/blob/main/AUTHORS yet? |
|
@danmar actually no i am not in it. You can add me as Sven Wienand |
I am not sure why the misra check for 17.3 was reduced to while and if statements but i think that shouldn't be the case. Now it should detect more / all functions which are implicitly called. I had a bit of a issue with function pointer defintion as the tokens ``` int16_t ( * misra_8_2_p_a ) () ``` cause the detection to trigger on the int16_t. But i filtered these false function pointer detection's explicitly. I also updated the test with the expected errors. As C89 is used i needed to add more expected 17.3 as needed. * printf_s * UINT32_C * va_copy are all not present in C89. But even if we bump up to C11 this PR #7325 would need to be merged before hand to actually get all the needed Identifiers.
Added a STDLIB_IDENTIFIERS for C11 as well as updated the C99 once based on,
C99: https://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf
C11: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
in the misra.py